#ifndef DIALOGCAMERASETUP_H
#define DIALOGCAMERASETUP_H
#include <QDialog>
#include <QPair>

/**
 * 相机辅助类，提供一个相机基本参数调节的对话框。
 * 这个类不直接操作相机，而是通过 signal-slot 方式传递命令传递命令。
 * 因此，这个对话框可以用于任意的相机参数控制。
 */

namespace Ui {
class DialogCameraSetup;
}

class DialogCameraSetup : public QDialog
{
    Q_OBJECT

public:
    explicit DialogCameraSetup(QWidget *parent = 0);
    ~DialogCameraSetup();
    void init();
    /**
     * @brief setShutterRange 设置曝光时间的范围
     * @param min
     * @param max
     */
    void setShutterRange(double min, double max);
    void setGainRange(double min, double max);
    void setGammaRange(double min, double max);
    void setBlackLevelRange(double min, double max);
    void setCameraVendor(QString vendor);
    void setCameraType(QString type);
    void setCameraID(QString id);
    void setCameraResolution(int width, int y);
    void enableGain(bool on);
    void enableBlackLevel(bool on);
    void enableGamma(bool on);
    void enableLightness(bool on);
    void enableContrast(bool on);
signals:   
    /**
     * @brief autoWhiteBalanceChanged
     * @param mode  0 表示关闭白平衡  1 表示单次白平衡   2 表示连续白平衡
     */
    void autoWhiteBalanceChanged(int mode);
    void autoWhiteBalanceOnce();
    void autoExposureContinuous(bool on);
    void autoWhiteBalanceOnceOff();

    void contrastChanged(double contrast);
    void lightnessChanged(double lightness);

    void exposureTimeAbsChanged(double exposure);
    void gainAbsChanged(double gain);
    void gainRawChanged(int gain);
    void blackLevelAbsChanged(double blackLevel);
    void blackLevelRawChanged(int level);
    void gammaChanged(double gamma);
public slots:
    /**
     * @brief updateExposureTimeAbs 设置曝光时间
     * @param exposure
     */
    void updateExposureTimeAbs(double exposure);
    void updateGainAbs(double gain);
    void updateGainRaw(int gain);
    void updateBlackLevelAbs(double level);
    void updateBlackLevelRaw(int level);
    void updateGamma(double gamma);
    void updateLightnessAbs(double lightness);
    void updateContrastAbs(double contrast);

private slots:
    void changeShutterIndex(int index);
    void changeAWB(int index);
    void changeGain(int value);
    void changeBlackLevel(int value);
    void changeContrast(int contrast);
    void changeLightness(int lightness);
    void changeGamma(int value);
private:
    Ui::DialogCameraSetup *ui;

    QPair<double, double> m_gainRange;
    QPair<double, double> m_gammaRange;
    QPair<double, double> m_blackLevelRange;
    QPair<double, double> m_exposureTimeRange;
    //GX_DEV_HANDLE m_hDevice;              ///< 设备句柄
};

#endif // DIALOGCAMERASETUP_H
